<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
    <title>产量数据输入</title>

    <!-- CSS  -->
    <#include "_css.ftl">
</head>
<body>
<#include "_nav.ftl">

<div class="layui-main" style="margin-top: 32px">
    <div class="site-title">
        <fieldset>
            <legend><a>${type_name}单位名称</a></legend>
        </fieldset>
    </div>
    <div class="layui-row" style="margin-top: 32px">
        <table lay-filter="factory-name-table" id="factory-name-table">
            <thead>
            <tr>
                <#list 1..factory_num as i>
                    <th lay-data="{field:'${i}',edit:'text'}">${type_name}${i}</th>
                </#list>
            </tr>
            </thead>
            <tbody>
            <tr>
                <#list 1..factory_num as i>
                    <td>a</td>
                </#list>
            </tr>
            </tbody>
        </table>
    </div>

    <div class="layui-form-item" style="margin-top: 32px;margin-left: -20px">
        <label class="layui-form-label">按月份筛选</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="time-filter">
        </div>
    </div>
    <div class="layui-row" style="margin-top: 32px">
        <table class="centered highlight ">
            <thead>
            <tr>
                <th>日期</th>
                <#list 1..factory_num as i>
                    <th>${type_name}${i}</th>
                </#list>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>2019.7.1</td>
                <#list 1..factory_num as i>
                    <td>10386</td>
                </#list>
            </tr>
            <tr>
                <td>2019.7.2</td>
                <#list 1..factory_num as i>
                    <td>10386</td>
                </#list>
            </tr>
            <tr>
                <td>2019.7.2</td>
                <#list 1..factory_num as i>
                    <td>10386</td>
                </#list>
            </tr>
            </tbody>
        </table>
    </div>

</div>

<#include "_js.ftl">
<script>
    $(function () {
        var type = ${type};
        var table = layui.table;

        table.init('factory-name-table', {});

        table.on('edit(factory-name-table)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            $.get('/product/edit', {type: type, id: field, name: value}, function (data) {
                layer.msg("修改成功！");
            });

        });

        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time-filter' //指定元素
            , type: 'month'
        });
    });
</script>
</body>
</html>
